<template>
	<view class="leave_box">
    <navTitle :titleRight="''" :title="'求職期望'"></navTitle>
    <view class="msg-box">
      <view class="fff-box">
        <view class="p-box">
          <view class="p-title">期望職位</view>
          <view class="p-input">
            <input placeholder="请输入職位名稱" v-model.trim="expect_job_name" />
          </view>
        </view>
        <view class="p-box">
          <view class="p-title">期望月薪</view>
          <view class="p-list">
            <!-- <view class="p-item" :class="myIndex==0?'active':''" @tap="handleMY()">面議</view> -->
            <!-- <view class="p-item" :class="myIndex==1?'active':''" @tap="handleMY()">選擇薪資範圍</view> -->
          </view>
          <block>
            <view class="p-title">最低薪資</view>
            <view class="p-input">
              <input placeholder="請選擇最低薪資" type="number" v-model.trim="expect_salary_min"/>
            </view>
            <view class="p-title">最高薪資</view>
            <view class="p-input">
              <input placeholder="请输入最高薪資" type="number" v-model.trim="expect_salary_max"/>
            </view>
          </block>
        </view>
      </view>
    </view>
    <view class="fixed-footer" @tap="handleNext()">
      <view>提交</view>
    </view>
	</view>
</template>

<script>
import navTitle from './../../boss/components/nav-title.vue';
import {userSaveIntention} from '../../../utils/userApi'
export default {
	components: {navTitle},
	data() {
		return {
      myIndex:0,
      expect_job_name:'',
      expect_salary_min:0,
      expect_salary_max:0,
		};
	},
	props: {
		couponList: {}
	},
	computed: {
  },
  created(){
  },
  onLoad(options) {
    if(options.expect_job_name){
      this.expect_job_name=options.expect_job_name?options.expect_job_name:''
      this.expect_salary_min=options.expect_salary_min
      this.expect_salary_max=options.expect_salary_max
    }
  },
	methods: {
    handleMY(){
      this.myIndex=1-this.myIndex
    },
    handleNext(){
      if(!this.expect_job_name){
        uni.showToast({
          icon:'none',
          title: '请输入職位名稱'
        })
        return
      }
      this.submitForm()
    },
    async submitForm(){
      let res=await userSaveIntention({
        expect_salary_min:this.expect_salary_min,
        expect_salary_max:this.expect_salary_max,
        expect_job_name:this.expect_job_name,
      })
      if(res.code==1){
        uni.showToast({
          icon:'none',
          title: '添加成功'
        })
        uni.navigateBack()
      }else{
        uni.showToast({
          icon:'none',
          title: res.msg||'系統異常'
        })
      }
    },
	}
};
</script>
<style lang="scss" scoped>
.leave_box{
  width: 100%;
  height: 100vh;
  overflow-y: scroll;
  background: #F4F6FA;
}
.msg-box{
  width: 100%;
  overflow-y: scroll;
  margin: 0 auto;
}
.fixed-footer{
  width: 100%;
  height: 50px;
  margin: 20px 0;
  view{
    width: calc(100% - 40px);
    height: 44px;
    line-height: 44px;
    text-align: center;
    background: linear-gradient( 90deg, #016CF1 0%, #0697F6 100%);
    border-radius: 8px;
    font-weight: 500;
    font-size: 15px;
    color: #FFFFFF;
    margin: 4px auto 0;
  }
}
.fff-box{
  background: #fff;
  width: calc(100% - 20px);
  border-radius: 10px;
  padding: 10px 20px;
  margin: 10px auto;
}
.p-title{
  height: 28px;
  font-weight: 500;
  font-size: 20px;
  color: #333333;
  line-height: 28px;
  margin: 10px 0 12px;
}
.p-list{
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  view{
    width: calc(50% - 6px);
    height: 50px;
    text-align: center;
    line-height: 50px;
    font-weight: 600;
    font-size: 16px;
    color: #333333;
    background: #F4F6FA;
    margin-bottom: 10px;
    border-radius: 8px;
  }
  view:nth-child(2n+1){
    margin-right: 10px;
  }
  view.active{
    color: #1C7AF7;
    border-radius: 8px;
    border: 1px solid #1C7AF7;
  }
}
.p-input{
  width: calc(100% - 20px);
  height: 50px;
  line-height: 50px;
  border-radius: 8px;
  border: 1px solid #C2C7CC;
  color: #808080;
  font-size: 16px;
  padding: 0 10px;
  input{
    width: 100%;
    height: 100%;
  }
}
.p-area{
  width: calc(100% - 20px);
  height: 200px;
  line-height: 40px;
  border-radius: 8px;
  border: 1px solid #C2C7CC;
  color: #808080;
  font-size: 16px;
  padding: 0 10px;
  textarea{
    width: 100%;
    height: 100%
  }
}
.picker-view {
  width: 750rpx;
  height: 600rpx;
  margin-top: 20rpx;
}
.item {
  line-height: 100rpx;
  text-align: center;
}
.margin-top-20{
  margin-top: 20px;
}
</style>
